﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//
using ddcCajamarca.BusinessEntities.AgendaCultural;


namespace ddcCajamarca.Repository.Mapping
{
    public class ActividadEventoMap:EntityTypeConfiguration<ActividadEvento>
    {
        public ActividadEventoMap()
        {
            this.HasKey(e => e.Id);

            this.Property(e => e.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(e => e.Nombre)
                .HasColumnType("varchar").HasMaxLength(500)
                .IsRequired();
            this.Property(e => e.Dia)
                .HasColumnType("date")
                .IsRequired();
            this.Property(e => e.HInicio)
                .HasColumnType("datetime2")
                .IsRequired();
            this.Property(e => e.HFin)
                .HasColumnType("datetime2")
                .IsRequired();
            
            //Relaciones
            this.HasRequired(a => a.Evento)
                .WithMany(a => a.ActividadesEvento)
                .HasForeignKey(a => a.EvenId)
                .WillCascadeOnDelete(true);//es true porque cuando se borra un evento tambien se borran las actividades

            this.HasRequired(a => a.Ambiente)
                .WithMany(a => a.IcActEventos)
                .HasForeignKey(a => a.LugarId)
                .WillCascadeOnDelete(false);

        }
    }
}
